﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Reflection;

namespace TaskSchedulingSystemForm.Model
{
    [XmlRoot("TaskConfig")]
    public class TaskConfig
    {
        /// <summary>
        /// 所有任务类型列表
        /// </summary>
        [XmlElement("TaskType")]
        public List<TaskType> allTaskType { set; get; }
    }
    public class TaskType
    {
        /// <summary>
        /// 任务类型名
        /// </summary>
        [XmlElement("TypeName")]
        public string TypeName { set; get; }    
        /// <summary>
        /// 任务列表
        /// </summary>
        [XmlElement("Task")]
        public List<TaskModel> taskLst { set; get; }
    }
    public class TaskModel : MarshalByRefObject
    {

        /// <summary>
        /// 任务类名（带命名空间）
        /// </summary>
        [XmlElement("TaskClass")]
        public string taskClass { set; get; }     
        /// <summary>
        /// 任务名称
        /// </summary>
        [XmlElement("TaskName")]
        public string taskName { set; get; }
        /// <summary>
        /// 任务程序集信息
        /// </summary>
        [XmlElement("TaskDllPath")]
        public string taskDllPath { set; get; }
        /// <summary>
        /// 任务执行时间生成规则
        /// </summary>
        [XmlElement("CronExpression")]
        public string cronExpression { set; get; }
        /// <summary>
        /// 该任务是否触发
        /// </summary>
        [XmlIgnore()]
        public bool isRunTask { set; get; }      
        /// 任务执行时输出的文本
        /// </summary>
        [XmlIgnore()]
        public string taskContext { set; get; }
        /// <summary>
        /// 任务线程id
        /// </summary>
        [XmlIgnore()]
        public int taskThreadId { set; get; }
        /// <summary>
        /// 任务下次启动时间
        /// </summary>
        [XmlIgnore()]
        public DateTime lastCarryTime { set; get; }
        /// <summary>
        /// 任务程序集实例
        /// </summary>
        [XmlIgnore]
        public Assembly ass { set; get; }
        /// <summary>
        /// 任务执行进度
        /// </summary>
        [XmlIgnore()]
        public int taskProcess { set; get; }

        /// <summary>
        /// 任务执行时所在的程序域
        /// </summary>
        [XmlIgnore()]
        public AppDomain ad { set; get; } 
    }
}
